#!/bin/bash

# 提前配置本地hosts文件
# 10.50.47.244 rocket_host

# 路径声明
path=$(pwd)
dataPath=$path/.docker
namesrvPath=$dataPath/namesrv
brokerPath=$dataPath/broker

#rocketmq version
version=5.1.0

# mqnamesrv
docker run -d --name rocketmq-namesrv  -p 9876:9876 \
-e "JAVA_OPT_EXT=-Xms256M -Xmx256M -Xmn128m" \
-v $namesrvPath/logs:/root/logs \
-v $namesrvPath/store:/root/store \
apache/rocketmq:$version \
sh mqnamesrv

# mqbroker
docker run -d --name rocketmq-broker-a  -p 10909:10909 -p 10911:10911 \
-e "JAVA_OPT_EXT=-Xms256M -Xmx256M -Xmn128m" \
-v $brokerPath/broker-a/logs:/root/logs \
-v $brokerPath/broker-a/store:/root/store \
-v $brokerPath/broker-a/conf:/home/rocketmq/rocketmq-$version/conf \
-v $path/broker.conf:/home/rocketmq/rocketmq-$version/conf/broker.conf \
apache/rocketmq:$version \
sh mqbroker -c /home/rocketmq/rocketmq-$version/conf/broker.conf


# web管理 rocketmq-dashboard
# rocket_host 须提前配置
docker run -d --name rocketmq-dashboard \
-e "JAVA_OPT_EXT=-Xms256M -Xmx256M -Xmn128m" \
-e "JAVA_OPTS=-Drocketmq.namesrv.addr=rocket_host:9876" \
-p 8080:8080 -t --name rocketmq-dashboard apacherocketmq/rocketmq-dashboard:latest
